import request from '../../utils/request';

// 用户管理相关 API

// 更新用户
export const updateUser = (data: any) => {
    return request({
        url: '/system/api/user/update',
        method: 'put',
        data
    });
};

// 修改密码
export const changePassword = (data: any) => {
    return request({
        url: '/system/api/user/change-password',
        method: 'put',
        data
    });
};

// 保存用户
export const saveUser = (data: any) => {
    return request({
        url: '/system/api/user/save',
        method: 'post',
        data
    });
};

// 根据ID获取用户
export const getUserById = (id: string) => {
    return request({
        url: `/system/api/user/${id}`,
        method: 'get'
    });
};

// 根据用户名获取用户
export const getUserByUsername = (username: string) => {
    return request({
        url: `/system/api/user/username/${username}`,
        method: 'get'
    });
};

// 根据手机号获取用户
export const getUserByPhone = (phone: string) => {
    return request({
        url: `/system/api/user/phone/${phone}`,
        method: 'get'
    });
};

// 分页查询用户
export const getUserPage = (params: any) => {
    return request({
        url: '/system/api/user/page',
        method: 'get',
        params
    });
};

// 获取用户列表
export const getUserList = () => {
    return request({
        url: '/system/api/user/list',
        method: 'get'
    });
};

// 获取当前用户信息
export const getCurrentUser = () => {
    return request({
        url: '/system/api/user/current',
        method: 'get'
    });
};

// 删除用户
export const deleteUser = (id: string) => {
    return request({
        url: `/system/api/user/${id}`,
        method: 'delete'
    });
};
